﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Bouyei.Discoverer
{
    using Class;

    public partial class FilterRules : Form
    {
        public FilterRules()
        {
            InitializeComponent();

            for (int i = 0; i < GlobalVariable.FilterItems.Count; ++i)
            {
                rtbFilterRules.AppendText(Encoding.Default.GetString(GlobalVariable.FilterItems[i]));
            }
        }

        private void btnClearFilterRules_Click(object sender, EventArgs e)
        {
            GlobalVariable.FilterItems.Clear();
            rtbFilterRules.Text = string.Empty;
        }

        private void btnSaveFilterRules_Click(object sender, EventArgs e)
        {
            if (rtbFilterRules.TextLength <= 0)
            {
                MessageBox.Show("请输入规则");
                return;
            }
            GlobalVariable.FilterItems.Clear();
            string[] rules = rtbFilterRules.Text.Trim().Split(';');
            for(int i=0;i<rules.Length;++i)
            {
                GlobalVariable.FilterItems.Add(Encoding.Default.GetBytes(rules[i]));
            }
            this.Close();
        }
    }
}
